import request from '@/utils/request'

export function gitInfo(filePath) {
  return request({
    url: '/system/firmware/gitInfo',
    method: 'get',
    params: {
      filePath: filePath,
    }
  });
}

export function uploadFirmware(file, path, deviceName, remark, version) {
  const data = new FormData();
  data.append('path', path);
  data.append('file', file);
  data.append('deviceName', deviceName);
  data.append('remark', remark);
  data.append('version', version);
  return request({
    url: '/system/firmware/uploadFirmware',
    method: 'post',
    data: data,
    headers: {
      'Content-Type': 'multipart/form-data',
    }
  });
}
export function getFile(path, commitId) {
  return request({
    url: '/system/firmware/getFile',
    method: 'get',
    responseType: 'blob',
    params: {
      path:path,
      commitId:commitId,
    }
  })
}

// 查询固件管理列表
export function listFirmware(query) {
  return request({
    url: '/system/firmware/list',
    method: 'get',
    params: query
  })
}

// 查询固件管理详细
export function getFirmware(id) {
  return request({
    url: '/system/firmware/' + id,
    method: 'get'
  })
}

// 新增固件管理
export function addFirmware(data) {
  return request({
    url: '/system/firmware',
    method: 'post',
    data: data
  })
}

// 修改固件管理
export function updateFirmware(data) {
  return request({
    url: '/system/firmware',
    method: 'put',
    data: data
  })
}

// 删除固件管理
export function delFirmware(id) {
  return request({
    url: '/system/firmware/' + id,
    method: 'delete'
  })
}
